#include "CRelation.h"


namespace csmodel
{
    /*
    CRelation::CRelation()
    {
        Connect( 0, 0 );
    }
    */
    //---------------------------------

    CRelation::CRelation( CPole * i, CPole * o )
    {
        Connect( i, o );
    }

    //---------------------------------

    void CRelation::Dispose()
    {
        if( in )
            in->rmConnector( this );
        if( out )
            out->rmConnector( this );
        Connect( 0, 0 );
    }

    //---------------------------------

    void CRelation::Draw( IDrawEngine &di ) const
    {
        if( in && out )
        {
            switch( type )
            {
                case StrippedPipe:
                    //break;
                case Arrowed:
                    //break;
                case NonArrowed:
                    di.Line( in->GetGlobalDims().center(), out->GetGlobalDims().center() );
                    break;
            }
        }
    }

    //---------------------------------

    void CRelation::Connect( CPole * i, CPole * o )
    {
        if( i && o && i != o )
        {
            in = i;
            out = o;
            in->addConnector( this );
            out->addConnector( this );
            type = NonArrowed;
        }
        else
        {
            in = 0;
            out = 0;
        }
    }

    //---------------------------------

}

